package com.his.disposal.controller;

import com.his.common.Result;
import com.his.disposal.pojo.Employee;
import com.his.disposal.pojo.MedicalTechnology;
import com.his.disposal.pojo.Register;
import com.his.disposal.service.DisposalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@RestController
@CrossOrigin("*")
@RequestMapping("disposal")
public class DisposalController {

        @Autowired
        private DisposalService disposalService;

        @GetMapping("query")
        public Result queryAllDisposal(){
            ArrayList<Register> disposal=disposalService.queryAllDisposal();
            System.out.println(disposal);
            if(disposal!=null){
                return new Result(1,"查询处置申请信息列表成功！",disposal);
            }
            else{
                return new Result(0,"查询处置申请信息列表失败！",null);
            }
        }

        @PostMapping("select")
        public Result queryDisposalByConditions(@RequestBody Register register){
            ArrayList<Register> list=disposalService.queryDisposalByConditions(register);
            System.out.println(list);
            if(list!=null){
                return new Result(1,"条件查询处置申请信息成功！",list);
            }
            else{
                return new Result(0,"条件查询处置申请信息失败！",null);
            }
        }
        //根据id拿到患者信息
        @PostMapping("selectById")
        public Result selectById(@RequestBody Register register){
            ArrayList<Register> list=disposalService.selectById(register);
            if(list!=null){
                System.out.println(list);
                return new Result(1,"条件查询处置申请信息成功！",list);
            }
            else{
                return new Result(0,"条件查询处置申请信息失败！",null);
            }
        }

        @PostMapping("select1")
        public Result queryEmployeeByConditions(@RequestBody Employee employee){
            ArrayList<Employee> list=disposalService.queryEmployeeByConditions(employee);
            if(list!=null){
                return new Result(1,"条件查询处置申请信息成功！",list);
            }
            else{
                return new Result(0,"条件查询处置申请信息失败！",null);
            }
        }
        @PostMapping("select2")
        public Result queryMedicalTechnologyByConditions(@RequestBody MedicalTechnology medicalTechnology) {
            ArrayList<MedicalTechnology> medicalTechnologyArrayList=disposalService.queryMedicalTechnologyByConditions(medicalTechnology);
            if(medicalTechnologyArrayList!=null){
                return new Result(1,"条件查询处置申请信息成功！",medicalTechnologyArrayList);
            }
            else{
                return new Result(0,"条件查询处置申请信息失败！",null);
            }
        }
    }


